﻿using NHibernate;
using NUnit.Framework;
using OpenWaves.ActivityFeed.UnitTests;
using OpenWaves.ActivityFeed.Web;

namespace OpenWaves.ActivityFeed.UnitTests_NHibernate
{
    public class NHibernateUpdatesBuilderTests : UpdatesBuilderTests
    {
        private ISessionFactory _sessionFactory;

        [SetUp]
        public void InitializeSessionFactory()
        {
            this._sessionFactory = NHibernateTestsUtils.CreateNHibernateTestsSessionFactory().CreateSessionFactory();
        }

        protected override IActivityFeedTestSession CreateSession()
        {
            var session = _sessionFactory.OpenSession();
            session.FlushMode = FlushMode.Commit;
            var transaction = session.BeginTransaction();

            return new NHibernateActivityFeedTestSession(session, transaction);
        }

        protected override ActivityFeedBuilder CreateActivityFeedBuilder(string subscriberId, IActivityFeedService activityFeedService)
        {
            return new OpenWaves.ActivityFeed.Web.NHibernate.PersonalActivityFeedBuilder(subscriberId, activityFeedService, this.updateDtoBuilder);
        }
    }
}